package com.hp.his.basic.dao;

import java.util.List;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import com.hp.his.basic.entity.UPMSIssue;
import com.hp.his.core.orm.Page;
import com.hp.his.core.orm.hibernate.HibernateDao;

/**
 * 
 *  针对医疗收费标准的增删改查操作 
 *  
 * @author liwenkui
 * @date 2011-7-12 上午09:46:46
 * 
 */
@Repository
public class UPMSIssueDao extends HibernateDao<UPMSIssue, Integer>{

	/**
	 * 按收费项目查询收费标准记录
	 * 
	 * @param page - 分页参数.
	 * @param value1 - 查询条件.
	 * @param value2 - 查询条件 .
	 * 
	 * @return 分页查询结果.附带结果列表及所有查询输入参数.
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Page<UPMSIssue> getAll(final Page<UPMSIssue> page){
		String hql = "from UPMSIssue";
		Query q = createQuery(hql);
		if (page.isAutoCount()) {
			long totalCount = countHqlResult(hql);
			page.setTotalCount(totalCount);
		}
		setPageParameterToQuery(q, page);
		List result = q.list();
		page.setResult(result);
		
		return page;
	}
//	public Page<UPMSIssue> searchFeeStandard(final Page<UPMSIssue> page, String query, final Object... values) {
//		
//		String hql = query +"(" + values[0] +","+values[1]+")";
//	
//		Query q = createQuery(hql);
//		
//		if (page.isAutoCount()) {
//			long totalCount = countHqlResult(hql);
//			page.setTotalCount(totalCount);
//		}
//
//		setPageParameterToQuery(q, page);
//
//		List result = q.list();
//		page.setResult(result);
//		return page;
//	}
	
	
	/**
	 * 根据收费标准名称的id来查询单价
	 * 
	 * @param id - 收费项目名称id.
	 * 
	 * @return 分页查询结果.附带结果列表及所有查询输入参数.
	 */
	@SuppressWarnings({ "rawtypes" })
	public UPMSIssue searchByIssueID(Integer id){
		//定义查询语句
		String hql = "from UPMSIssue where issueId="+id;
		Query query = getSession().createQuery(hql);
		
		List list = query.list();
		UPMSIssue entity = (UPMSIssue)list.get(0);
		
		return entity;
	}
}
